<template>
  <el-container class="home-container">
    <!-- 头部 -->
    <el-header>
      <div>
        <my-image
          :src="require('@/assets/img/logo.jpg')"
          fit="cover"
          class="logo"
        />
        <span>电商后台管理系统</span>
      </div>
      <el-button type="info" @click="logout">退出登陆</el-button>
    </el-header>
    <el-container>
      <!-- 左侧菜单 -->
      <el-aside :width="collapse ? '64px' : '15%'">
        <div class="togButton" @click="togoClose" >|||</div>
        <left-menu :collapse="collapse"></left-menu>
      </el-aside>
      <!-- 主体 -->
      <el-main>
        <router-view v-slot="{ Component }">
          <transition>
            <keep-alive>
              <component :is="Component"></component>
            </keep-alive>
          </transition>
        </router-view>
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
import LeftMenu from "./HomeCom/leftMenu.vue";

export default {
  name: "Home",
  data() {
    return {
      collapse: false,
      menuWidth: "15%"
    };
  },
  methods: {
    logout() {
      window.sessionStorage.clear();
      this.$router.push("/Login");
    },
    //切换菜单显示
    togoClose(){
      this.collapse=!this.collapse;
    }
  },

  mounted() {},
  components: {
    LeftMenu,
  },
};
</script>

<style lang="less" scoped>
.el-header {
  background-color: #525557;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-left: 0;
  > div {
    display: flex;
    align-items: center;
  }
  .logo {
    width: 60px;
    height: 100%;
    border-radius: 50%;
  }
  span {
    color: white;
    font-size: 20px;
    margin-left: 15px;
  }
}

.el-aside {
  background-color: #5b5e66;
  
}

.el-main {
  background-color: rgb(224, 224, 224);
  width: 80%;
}
.home-container {
  height: 100%;
}

.togButton{
  background-color: #909399;
  color: white;
  text-align: center;
  letter-spacing: 0.2em;
  font-size: 10px;
  line-height: 24px;
  cursor: pointer;
}
</style>
